//
//  CLstrollTableCell.m
//  I-want-go
//
//  Created by dllo on 15/10/26.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "CLstrollTableCell.h"
#import "CLtitleCollectionCell.h"
#import "CLtitlePictrue.h"
#import "CLtool.h"
#import "CLscreen.h"
@interface CLstrollTableCell ()<   UICollectionViewDataSource, UICollectionViewDelegate>
@property(nonatomic, retain)NSMutableArray *arr;

@end
@implementation CLstrollTableCell

- (void)dealloc {
    [_myCollectionView release];
    [_arr release];
    [_titArr release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
    }
    return self;
}

- (void)createView {
    
    //////collectionView
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
    flowLayout.itemSize = CGSizeMake(72 * SWIDTH, 105 * SHEIGHT);
    
    self.myCollectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, 375 * SWIDTH, 250 * SHEIGHT) collectionViewLayout:flowLayout];
    [self.contentView addSubview:self.myCollectionView];
    
    [_myCollectionView release];
    self.myCollectionView.backgroundColor = [UIColor whiteColor];
    [self.myCollectionView registerClass:[CLtitleCollectionCell class] forCellWithReuseIdentifier:@"rea"];
    flowLayout.sectionInset = UIEdgeInsetsMake(20 * SHEIGHT, 5 * SWIDTH, 2 * SWIDTH, 2 * SHEIGHT);
    
    
    
    self.myCollectionView.dataSource = self;
    self.myCollectionView.delegate = self;
    
}


- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return 7;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    CLtitleCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"rea" forIndexPath:indexPath];
    cell.backgroundColor = [UIColor whiteColor];
    
    
    CLtitlePictrue *pic = self.titArr[indexPath.row];
    cell.myLabel.text = pic.name;
    
    [cell.picImage sd_setImageWithURL:[NSURL URLWithString:pic.logo]];
    return cell;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    CLtitlePictrue *pi = self.titArr[indexPath.row];
//    NSString *sttId = pi.picId;
    [self.delate pushindexid:pi.picId Withname:pi.name];
    
}

















- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
